package com.szt.ynb.server.router.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

@Entity
public class Server implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = -3821362004073636339L;
	
	/****
	 * 状态在线
	 */
	public static final Integer STATUS_ONLINE = 1;
	
	/***
	 * 状态离线
	 */
	public static final Integer STATUS_OFFLINE = -1;
	
	/***
	 * 状态-强制离线
	 */
	public static final Integer STATUS_FORSE_OFFLINE = -2;
	
	/***
	 * 状态-默认
	 */
	public static final Integer STATUS_DEFAULT = -3;
	
	@Id
	@GeneratedValue
	private Long id;
	
	/***
	 * 服务名称
	 */
	@Column(nullable = false)
	private String serverName;
	
	/***
	 * 版本
	 */
	@Column(nullable = false)
	private String version;
	
	/***
	 * url地址
	 */
	@Column(nullable = false)
	private String url;
	
	/***
	 * 状态
	 */
	@Column(nullable = false)
	private Integer status;
	
	/***
	 * 服务添加时间
	 */
	@Column(nullable = false)
	private Date addDate;
	
	/***
	 * 状态更新时间
	 */
	@Column(nullable = false)
	private Date updateDate;
	
	/***
	 * 评分
	 */
	@Column(nullable = false)
	private Integer score;
	
	public Server() {
	}
	
	public Server(String serverName, String version, String url) {
		this(serverName, version, url, STATUS_ONLINE, new Date(), new Date(), 80);
	}
	
	public Server(String serverName, String version, String url, Integer status, Date addDate, Date updateDate,
			Integer score) {
		super();
		this.serverName = serverName;
		this.version = version;
		this.url = url;
		this.status = status;
		this.addDate = addDate;
		this.updateDate = updateDate;
		this.score = score;
	}
	
	public String getStatusStr() {
		if (status == STATUS_ONLINE) {
			return "上线";
		} else if (status == STATUS_OFFLINE) {
			return "离线";
		} else if (status == STATUS_FORSE_OFFLINE) {
			return "强制离线";
		} else if (status == STATUS_DEFAULT) {
			return "重置状态";
		}
		return "";
	}
	
	public String getServerName() {
		return serverName;
	}
	
	public void setServerName(String serverName) {
		this.serverName = serverName;
	}
	
	public String getVersion() {
		return version;
	}
	
	public void setVersion(String version) {
		this.version = version;
	}
	
	public String getUrl() {
		return url;
	}
	
	public void setUrl(String url) {
		this.url = url;
	}
	
	public Integer getStatus() {
		return status;
	}
	
	public void setStatus(Integer status) {
		this.status = status;
	}
	
	public Date getAddDate() {
		return addDate;
	}
	
	public void setAddDate(Date addDate) {
		this.addDate = addDate;
	}
	
	public Date getUpdateDate() {
		return updateDate;
	}
	
	public void setUpdateDate(Date updateDate) {
		this.updateDate = updateDate;
	}
	
	public Long getId() {
		return id;
	}
	
	public void setId(Long id) {
		this.id = id;
	}
	
	public Integer getScore() {
		return score;
	}
	
	public void setScore(Integer score) {
		this.score = score;
	}
	
}
